.TH getchar 3 "" "" ""
.SH SYNOPSIS
getchar \- read a character (macro)
.SH ANSI_SYNOPSIS
#include <stdio.h>
.br
int getchar(void);
.br

int _getchar_r(void *
.IR reent );
.br
.SH TRAD_SYNOPSIS
#include <stdio.h>
.br
int getchar();
.br

int _getchar_r(
.IR reent )
.br
char * 
.IR reent ;
.br
.SH DESCRIPTION
.BR getchar 
is a macro, defined in 
.BR stdio.h .
You can use 
.BR getchar 
to get the next single character from the standard input stream.
As a side effect, 
.BR getchar 
advances the standard input's
current position indicator.

The alternate function 
.BR _getchar_r 
is a reentrant version. The
extra argument 
.IR reent 
is a pointer to a reentrancy structure.
.SH RETURNS
The next character (read as an 
.BR unsigned char ,
and cast to
.BR int ),
unless there is no more data, or the host system reports a
read error; in either of these situations, 
.BR getchar 
returns 
.BR EOF .

You can distinguish the two situations that cause an 
.BR EOF 
result by
using `
.BR ferror(stdin) '
and `
.BR feof(stdin) '.
.SH PORTABILITY
ANSI C requires 
.BR getchar ;
it suggests, but does not require, that
.BR getchar 
be implemented as a macro.

Supporting OS subroutines required: 
.BR close ,
.BR fstat ,
.BR isatty ,
.BR lseek ,
.BR read ,
.BR sbrk ,
.BR write .
.SH SOURCE
src/newlib/libc/stdio/getchar.c
